home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / VieGOPHER / rosetex.awk < prev    next >
Encoding:
AWK Script  |  1993-06-16  |  2.8 KB  |  117 lines

  1. #
  2. # FILE rosetex.awk
  3. #
  4. # translate ROSE product file into LaTeX format for printing
  5. #
  6. # written:       1992-10-23 <Gerhard.Gonter@wu-wien.ac.at>
  7. # latest update: 1993-05-29
  8. #
  9. # ----------------------------------------------------------------------------
  10. BEGIN {
  11.   verb=0;
  12.   xverb=-1;
  13.   emptyline=0;          # number of empty lines suppressed in verbatim env.
  14.   args["#erase"]="\\subsection";
  15.   argt["#erase"]="Module";
  16.   args["#help"]="\\subsection";
  17.   argt["#help"]="{\\sl{help}}";
  18. }
  19. # ----------------------------------------------------------------------------
  20. $1=="#section"||$1=="#subsection"||$1=="#subsubsection"||$1=="#paragraph" {
  21.   if (verb==1) {
  22.     print "\\end{verbatim}\n";
  23.     verb=0;
  24.   }
  25.   nm=substr($0,length($1)+2);
  26.   print "\\"substr($1,2)"{"nm"}\n";
  27.   if ($1=="#section") {
  28.     print "\\def\\LPtopC{"nm"}\n";
  29.     print "\\def\\LPtopD{~}\n";
  30.     print "\\def\\LPtopF{~}\n";
  31.   }
  32.   if ($1=="#subsection") {
  33.     print "\\def\\LPtopD{"nm"}\n";
  34.     print "\\def\\LPtopF{~}\n";
  35.   }
  36.   if ($1=="#subsubsection") {
  37.     print "\\def\\LPtopF{"nm"}\n";
  38.   }
  39.   next;
  40. }
  41.  
  42. # ----------------------------------------------------------------------------
  43. $1=="#erase"||$1=="#help" {
  44.   if (verb==1) {
  45.     print "\\end{verbatim}\n";
  46.     verb=0;
  47.   }
  48.   nm=substr($0,length($1)+2);
  49.   gsub("_","\\_",nm);
  50.   print args[$1]"{"argt[$1]" {\\tt "nm"}}\n"
  51.   print "\\def\\LPtopD{"argt[$1]" {\\tt "nm"}}\n";
  52.   print "\\def\\LPtopF{~}\n";
  53. #  /* this line needs to be printed too! */
  54. }
  55.  
  56. # ----------------------------------------------------------------------------
  57. $1=="#end" {
  58.   if (verb==1) {
  59.     print "\\end{verbatim}\n";
  60.     verb=0;
  61.   }
  62.   next;
  63. }
  64.  
  65. # ----------------------------------------------------------------------------
  66. $1=="#organize" {
  67.   args[$2]=$3;
  68.   argt[$2]=$4;
  69. }
  70.  
  71. # ----------------------------------------------------------------------------
  72. $1=="#verbatim" {
  73.   xverb=verb;
  74.   verb=2;
  75.   next;
  76. }
  77.  
  78. # ----------------------------------------------------------------------------
  79. $1=="#v" {
  80.   print substr($0,4);
  81.   next;
  82. }
  83.  
  84. # ----------------------------------------------------------------------------
  85. $1=="#endverbatim" {
  86.   verb=xverb;
  87.   next;
  88. }
  89.  
  90. # ----------------------------------------------------------------------------
  91. verb==0&&$0!=""&&$0!=" " {
  92.   print "\\begin{verbatim}"
  93.   verb=1;
  94.   emptyline=0;
  95. }
  96.  
  97. # ----------------------------------------------------------------------------
  98. verb==1 {
  99.   if ($0==""||$0==" ") {
  100.     emptyline++;
  101.   } else {
  102.     for (; emptyline>0; emptyline--) print "";  # make empty line
  103.     print
  104.   }
  105. }
  106.  
  107. # ----------------------------------------------------------------------------
  108. verb==2 { print }       # LaTeX section in ROSE product file
  109.  
  110. # ----------------------------------------------------------------------------
  111. END {
  112.   if (verb==1) {
  113.     print "\\end{verbatim}\n";
  114.     verb=0;
  115.   }
  116. }
  117.